//AJAX验证相关
//=============================================================

//Ajax验证开好站表单
function aj_check_opening(value, type, obj) {
	$.ajax({
		type:"POST",
		url:"/ajax/check_opening/",
		data:"value="+value+"&type="+type,
		success:function(data){
			if(data != "") {
				show_validator_msg(obj, data);
			} else {
				show_validator_msg(obj, '');
			}
		}
	});
}

//联动选择分类
function aj_change_class(parentid) {
	$.ajax({
		type:"POST",
		url:"/ajax/change_class/",
		data:"parentid="+parentid,
		success:function(data){
			var obj = $("#subclass");
			if(data != "") {
				obj.html(data);	
			} else {
				obj.html('<option value="0">请选择</option>');
			}
		}
	});
}

//JS验证表单相关
//=============================================================

//检测开好站表单step1
function check_opening_form1(form) {
	var empty_name = empty_domain = false;
	//验证字段
	empty_name = check_empty_field(form.name, "name", "好站名称");
	empty_domain = check_empty_field(form.domain, "domain", "好站域名");
	//验证分类
	if(form.topclass.value == 0 || form.subclass.value == 0) {
		$("#class_msg").html("请选择分类");
		return false;
	} else {
		$("#class_msg").html("");
	}
	if(empty_name || empty_domain) {
		return false;	
	}
}

//检测开好站表单step2
function check_opening_form2(form) {
	var empty_realname = empty_usermail = empty_phone = empty_reason = false;
	//验证字段
	empty_realname = check_empty_field(form.realname, "realname", "真实姓名");
	empty_usermail = check_empty_field(form.usermail, "usermail", "Email");
	empty_phone = check_empty_field(form.phone, "phone", "电话");
	empty_reason = check_empty_field(form.reason, "reason", "申请事由");
	if(empty_realname || empty_usermail || empty_phone || empty_reason) {
		return false;	
	}
}

//检测同意
function check_agree() {
	if($("#agree").attr("checked")){
		$("#dosubmit").attr("disabled", "");
	} else {
		$("#dosubmit").attr("disabled", "true");	
	}
}
//=============================================================
